/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef KH_SLE_SEEK_H
#define KH_SLE_SEEK_H

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

#include <stdlib.h>
#include "sle_error_code.h"
#include "sle_seek_config.h"

/**
 * @brief   Seek state change callback
 *
 * @param  [in] seekState - seek state
 * @return  None
 */
typedef void (*SleSeekStateChangeCallback)(SleSeekState seekState);

/**
 * @brief  Seek result callback
 *
 * @param  [in] result - seek result
 * @return  None
 */
typedef void (*SleSeekResultCallback)(SleSeekResult *result);

typedef struct {
    SleSeekStateChangeCallback OnSleSeekStateChangeCb;
    SleSeekResultCallback OnSleSeekResultCb;
} SleSeekCallbacks;

/**
 * @brief  Initialize seek module sync
 *
 * @param  None
 * @return  SleErrorCode - operation result
 */
SleErrorCode InitSleSeekService(void);

/**
 * @brief  Deinitialize seek module sync
 *
 * @param  None
 * @return  SleErrorCode - operation result
 */
SleErrorCode DeinitSleSeekService(void);

/**
 * @brief  Start seek sync
 *
 * @param   [in] param - seek parameters
 * @return  SleErrorCode - operation result
 *
 * @note    result return in SleSeekTimeOut = 3s
 * @note    device result return in callback: SleSeekResultCallback
 */
SleErrorCode StartSeek(const SleSeekParam *param);

/**
 * @brief  Stop seek sync
 *
 * @param  None
 * @return  SleErrorCode - operation result.
 *
 * @note    result return in SleSeekTimeOut = 3s
 */
SleErrorCode StopSeek(void);

/**
 *  @brief  get deault seek param sync
 *
 *  @param  [out] seekConfig - seek param config
 *  @return SleErrorCode - operation result
 */
SleErrorCode GetDefaultSeekParamConfig(SleSeekParam *seekConfig);

/**
 * @brief  Register seek result callback
 *
 * @param  [in] seekCallback - seek result callback
 * @return  SleErrorCode - operation result
 */
SleErrorCode RegisterSeekCallbacks(SleSeekCallbacks *seekCallback);

/**
 * @brief  Unregister seek result callback
 *
 * @param  [in] seekCallback - seek result callback
 * @return  SleErrorCode - operation result
 */
SleErrorCode UnregisterSeekCallbacks(SleSeekCallbacks *seekCallback);

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // SLE_SEEK_H